package com.itheima.fanxing;

import com.itheima.domain.Student;

import java.util.ArrayList;

/*
泛型通配符
 */
public class Demo07 {
    public static void main(String[] args) {

        ArrayList<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        print(list);
        ArrayList<Student> list1 = new ArrayList<>();
        list1.add(new Student("zhangsan1",28));
        list1.add(new Student("zhangsan2",28));
        list1.add(new Student("zhangsan3",28));
        list1.add(new Student("zhangsan4",28));
        print(list1);


    }


    //定义方法 遍历集合
    public static void print(ArrayList<?> list){
        for (int i = 0; i < list.size(); i++) {

            Object o = list.get(i);
            System.out.println(o);
        }
    }
}
